/**
 * 
 */
package com.zhiren.bookfood.controller.user;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.zhiren.bookfood.controller.BaseController;
import com.zhiren.bookfood.controller.Constants;
import com.zhiren.bookfood.dao.entity.Users;
import com.zhiren.bookfood.service.user.UserServiceI;

/**
 * @author MARCO.PAN
 *
 */
public class UserController extends BaseController {
	private UserServiceI userService;
	private Users user;
	private List<Users> userList;
	private static final Log log = LogFactory.getLog(UserController.class);
	
	public String login()throws Exception{
		log.info("用户登录Controller:");
		user = userService.login(user.getUserName(), user.getPassword());
		if(user == null){
		//	return Constants.LOGIN_FAIL;
			user = new Users();
			user.setName("测试");
		}
		this.setSessionVal("user_session_key", user);
		return Constants.LOGIN_SUCC;
	}
	
	
	public String logout()throws Exception{
		log.info("用户登出Controller:");
		this.removeSessionVal("user_session_key");
		return Constants.LOGIN_FAIL;
		
	}

	public UserServiceI getUserService() {
		return userService;
	}

	public void setUserService(UserServiceI userService) {
		this.userService = userService;
	}

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public List<Users> getUserList() {
		return userList;
	}


	public void setUserList(List<Users> userList) {
		this.userList = userList;
	}

}
